package electionView;
//import electionCtrl.Admin;
//import electionCtrl.Candidate;
//import electionCtrl.Election;
import electionCtrl.ElectionController;
import javax.xml.stream.XMLStreamException;
import java.io.FileNotFoundException;

public class ElectionRunner
{
	/**
	 * This is the main class. It test most of the methods that have been stringed together.
	 * It asks the user how many voters there will be and then generates that number of passwords so people can vote.
	 * Then it gives the user a warning to enter all the candidate's information in the correct positions.
	 * After that it creates a candidates array for use in other classes.
	 * The only problem with this main class is the fact of I dont know what to do with the counted values.
	 * Other than that it everything works. 
	 **/
	public static void main(String[] args) throws XMLStreamException, FileNotFoundException {
		//		int number = Integer.parseInt(JOptionPane.showInputDialog("How many voters are there? (Enter numeric value): "));
		//		JOptionPane.showMessageDialog(null,"Please enter all the Candidate's information within the corresponding fields.");
		//		JOptionPane.showMessageDialog(null,"Once all the items in the fields are correct, hit the submit button. \n Then edit the fields again for the next candidate and hit submit to add the next candidate.");
		//		CandidateListDemo list = new CandidateListDemo();
/*		Candidate[] canList = new Candidate [8];
		canList[0] = new Candidate("Dan Onorato & H. Scott Conklin", Candidate.Seat.GOVERNOR, "Democrat");
		canList[1] = new Candidate("Tom Corbett & Jim Cawley", Candidate.Seat.GOVERNOR, "Republican");
		//canList[2] = new Candidate("H. Scott Conklin", Candidate.Seat.LT_GOVERNOR, "Democrat");
		//canList[3] = new Candidate("Jim Cawley", Candidate.Seat.LT_GOVERNOR, "Republican");
		canList[2] = new Candidate("Dan B. Frankel", Candidate.Seat.PENN_HOUSE, "Democrat");
		canList[3] = new Candidate("Daniel Ulrich Wiseman", Candidate.Seat.PENN_HOUSE, "Republican");
		//canList[4] = new Candidate("Candidate7", Candidate.Seat.PENN_SENATE, "Democrat");
		//canList[5] = new Candidate("Candidate8", Candidate.Seat.PENN_SENATE, "Republican");
		canList[4] = new Candidate("Mike Doyle", Candidate.Seat.US_HOUSE, "Democrat");
		canList[5] = new Candidate("Melissa Haluszczak", Candidate.Seat.US_HOUSE, "Republican");
		canList[6] = new Candidate("Joe Sestak", Candidate.Seat.US_SENATE, "Democrat");
		canList[7] = new Candidate("Pat Toomey", Candidate.Seat.US_SENATE, "Republican");*/


		//Election elec = new Election(canList);
		//ElectionController elecCtrl = new ElectionController(".\\data\\Ballot Definition1.blt");
		//		elec.generatePassList(number);
		
//		OverviewGui elecG = new OverviewGui(canList, admin, elec);
//		elecG.createGui();
//		elecG.showWindow();

		ElectionController elecCtrl;
		if (args.length > 0)
		{
			elecCtrl = new ElectionController(args[0]);//otherwise, construct it out of the passed XML file
		}
		else
		{
			elecCtrl = new ElectionController();//if there's no name specified, prompt for input	
		}
		try
		{
			elecCtrl.run();
		}
		catch(InterruptedException e)
		{
			System.err.println("Fatal Error: Thread interrupted prematurely.  Program will now terminate");
			e.printStackTrace();
		}
		System.exit(0);
	}
}
